# 判断年龄是否是成年人 练习
import random
import time

# print("请输入您的年龄")
# age = input()
#
# if not age.isdigit():
#     print("您输入的年纪不合法")
#     exit(0)
#
# age = int(age)
#
# price = 10
# if age >= 18:
#     print(f"您已成年，需要补票{price}元")
# elif 18 > age >= 10:
#     print(f"您是青少年，需要补票{price - 5}元")
# else:
#     print("您是儿童！")
# print("祝您玩的愉快")

# 猜数字游戏
print("正在准备数字中....")

num = random.randint(0, 10)
time.sleep(random.randint(1, 5))
print("需要猜测的数字已生成，范围0-10")
count = 1
total = 3

while count <= total:
    guessNum = input("请输入您猜测的数字：")
    if not guessNum.isdigit():
        print("您输入的并非纯数字，请重新输入")
    else:
        guessNum = int(guessNum)
        if guessNum == num:
            print(f"恭喜您，猜中了，它是{num}")
            break
        else:
            if count == total:
                print(f"抱歉，您都没猜中，正确数字是{num}")
            else:
                propStr = "您猜大了" if guessNum > num else "您猜小了"
                print(f"{propStr}，您还有{total - count}次机会")

        count += 1

print("游戏结束")
